package com.codeforces.contest.c34;

import java.util.Iterator;
import java.util.Scanner;
import java.util.Vector;

public class _34D {

	static Scanner scanner = new Scanner(System.in);
	static int n,r1, r2;
	static int[] p, vis;
	static Vector<Integer>[] vects;

	public static void main(String[] args) {
		n = scanner.nextInt();
		r1 = scanner.nextInt();
		r2 = scanner.nextInt();
		p = new int[n+1];
		vis = new int[n+1];
		vects = new Vector[n+1];
		for (int i=1;i<=n;++i) {
			vects[i] = new Vector<Integer>();
		}
		for (int i=1;i<=n;++i) {
			if (i != r1) {
				p[i] = scanner.nextInt();
				vects[i].add(p[i]);
				vects[p[i]].add(i);
			}
		}
		vis[r2] = 1;
		dfs(r2);
		for (int i=1;i<=n;++i) {
			if (i != r2) {
				System.out.print(p[i]);
			}
			if (r2 == n) {
				if (i < n-1) {
					System.out.print(" ");
				}
				else {
					System.out.println();
				}
			}
			else {
				if (i < n && i != r2) {
					System.out.print(" ");
				}
				else if (i == n) {
					System.out.println();
				}
			}
		}
	}

	private static void dfs(int root) {
		Iterator<Integer> it = vects[root].iterator();
		while (it.hasNext()) {
			int next = it.next();
			if (vis[next] != 1) {
				vis[next] = 1;
				p[next] = root;
				dfs(next);
			}
		}
	}

}
